from aiogram import Router, F
from aiogram.filters import Command
from aiogram.fsm.context import FSMContext
from aiogram.types import Message, ReplyKeyboardRemove
from fluent.runtime import FluentLocalization

from recruit_bot.dialogs import created_template_cv
from recruit_bot.handlers.state import TemplateCVState
from recruit_bot.keyboards.template_keyboards import (
    set_keyboard,
    BUTTON_TEMPLATE_VACANCY,
    BUTTON_TEMPLATE_CV,
)

router = Router()


@router.message(Command('template'))
async def select_template(message: Message, l10n: FluentLocalization) -> None:
    await message.answer(
        l10n.format_value('template'),
        reply_markup=set_keyboard()
    )


@router.message(F.text.lower() == BUTTON_TEMPLATE_VACANCY.lower())
async def create_template_vacancy(
        message: Message,
        l10n: FluentLocalization
) -> None:
    await message.answer(
        l10n.format_value('template_vacancy'),
        reply_markup=ReplyKeyboardRemove()
    )


@router.message(F.text.lower() == BUTTON_TEMPLATE_CV.lower())
async def create_template_cv(
        message: Message,
        l10n: FluentLocalization,
        state: FSMContext
) -> None:
    await message.answer(
        l10n.format_value('template_cv'),
        reply_markup=ReplyKeyboardRemove()
    )
    await created_template_cv.send_user_info(message, l10n)
    await state.set_state(TemplateCVState.info_cv)
